﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace DifferentArtists
{
    class TestSelect
    {
        static void Main(string[] args)
        {
            string xmlFilePath = @"..\..\catalog.xml";
            XmlDocument xml = new XmlDocument();
            xml.Load(xmlFilePath);

            Dictionary<string, int> artistAlbums = new Dictionary<string, int>();
            foreach (XmlNode item in xml.DocumentElement)
            {
                if (!artistAlbums.ContainsKey(item["artist"].InnerText))
                {
                    artistAlbums.Add(item["artist"].InnerText, 1);
                }
                else
                {
                    artistAlbums[item["artist"].InnerText]++;
                }
            }

            foreach (KeyValuePair<string,int> pair in artistAlbums)
            {
                Console.WriteLine("artist: "+pair.Key+", albums: "+pair.Value);
            }
        }
    }
}
